package org.example.bigdata.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.bigdata.dto.LoginFormDto;
import org.example.bigdata.entity.User;
import org.example.bigdata.service.UserService;
import org.example.bigdata.utils.Result;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户注册
     * @param user
     * @return
     */
    @PostMapping("/register")
    public Result register(@RequestBody User user){
       return userService.register(user);
    }

    /**
     * 用户登录
     * @param loginFormDto
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody LoginFormDto loginFormDto){
        return userService.login(loginFormDto);
    }

    @GetMapping("/getUserInfo")
    public Result getUserInfo(@RequestHeader("token") String token){
        return userService.getUserInfo(token);
    }



}
